#!/usr/bin/python

from datetime import datetime

from vateblog.model.Post import Post

from AdminHandlerBase import AdminHandlerBase

class NewPostHandler(AdminHandlerBase):

    def admin(self):
        title = self.request.get('title')
        body = self.request.get('body')
        publish = self.request.get('publish')
        if publish is None or publish == "":
            status = Post.DRAFT
        else:
            status = Post.PUBLISH

        post = Post(title=title, body=body, author=self.get_current_user(),
            time=datetime.now(), status=status)
        post.put()
